﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MockPrjTeam1.Biz;
using MockPrjTeam1.Entity;
using MockPrjTeam1.DAO;
using System.Data;
using System.Data.SqlClient;

namespace MockPrjTeam1.Pages.Views
{
    public partial class ContactLookup : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var biz = new ContactBiz();

                var results = biz.GetAll();
                grvLookupContact.DataSource = results;
                grvLookupContact.DataBind();
            }
        }
        protected void PageChange(object sender, EventArgs e)
        {
            grvLookupContact.PageIndex++;
            grvLookupContact.DataBind();
        }     
       
        protected void grvLookupContact_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            var biz = new ContactBiz();

            var results = biz.GetAll();
            grvLookupContact.PageIndex = e.NewPageIndex;
            grvLookupContact.DataSource = results;
            grvLookupContact.DataBind();
        }

        protected void grvLookupContact_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
        //public void selectradio()
        //{
        //    Response.Redirect("../../Pages/Forms/ContactDetail.aspx?mid={0}", false);
        //}

        
        protected void btnSearchContact1_Click(object sender, EventArgs e)
        {
            var FirstName = Convert.ToString(txtFirstName.Text);
            var SurName = Convert.ToString(txtSurName.Text);

            var biz = new ContactBiz();
            var result = biz.SearchContact(FirstName, SurName); 
            grvLookupContact.DataSource = result;
            grvLookupContact.DataBind();

        }
        //protected void btnSelect_Click(object sender, EventArgs e)
        //{
        //    ClientScript.RegisterStartupScript(GetType(), "id", "getSelectedItem();", true);
        //}
       
    }
}